package com.wswy.wzcx.model.core

import android.annotation.SuppressLint
import android.content.Intent
import android.content.pm.PackageManager
import android.net.Uri
import com.blankj.utilcode.util.RomUtils
import com.wswy.wzcx.AppContext
import com.wswy.wzcx.BuildConfig
import com.wswy.wzcx.module.HomeNewsCategoryLoader
import com.wswy.wzcx.module.MessageCenter
import com.wswy.wzcx.module.NewsTabCategoryLoader
import com.wswy.wzcx.module.TabConfLoader
import com.wswy.wzcx.utils.RxUtils
import io.reactivex.Maybe
import org.greenrobot.eventbus.EventBus
import timber.log.Timber

/**
 * 预加载数据
 */
object PreLoader {

    private const val TAG = "PreLoader"



    @JvmStatic
    fun load(){
        loadCars()
        loadModules()
        loadNews()
    }

    /**
     *
     */
    private fun loadCars(){

    }

    private fun loadModules(){

        //加载模块
        TabConfLoader(AppContext.getContext()).loader {
            EventBus.getDefault().postSticky(EventTabConfResp(it.orNull()))

        }

    }

    private fun loadNews(){

        //加载新闻配置
        HomeNewsCategoryLoader().loader {

            EventBus.getDefault().postSticky(EventNewsCategory(it.orNull()))
        }

        NewsTabCategoryLoader().loader {
            EventBus.getDefault().postSticky(EventTabNewsCategory(it.orNull()))
        }

    }

    @JvmStatic
    fun reloadTabs(){
        TabConfLoader(AppContext.getContext()).loadOnce {
            EventBus.getDefault().postSticky(EventTabConfResp(it.orNull()))
        }
    }

}